package demo;

public class Test {
    public static void test1(Animals animals){
        animals.eat();
    }
    public static void test4(IFlying iFlying){
        iFlying.fly();
    }
    public static void test2(IRunning iRunning){
        iRunning.run();
    }
    public static void test3(ISwimming iSwimming){
        iSwimming.swim();
    }

    public static void main1(String[] args) {
        Bird bird = new Bird("小鸟",1);
        Dog dog = new Dog("小狗",10);
        test1(dog);
        test1(bird);
    }

    public static void main(String[] args) {
        Bird bird = new Bird("小鸟",1);
        Dog dog = new Dog("小狗",10);
        test1(dog);
        test1(bird);

        test2(bird);
        test2(dog);
        System.out.println("============");
        test3(dog);
        //test3(bird);bird没有实现swimming的接口
        System.out.println("============");
        test4(bird);
        //test4(dog);dog没有实现了flying的接口
        test2(new Robot());//这个我时候我只要实现了test2就可以了，实现了这个的接口就可以了，不用去管这个animals类
        //这个时候我们就可以发现了这个接口回避向上转型会更加灵活
    }
}
